home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
c't freeware shareware 1999 February
/
CT_SW9902.ISO
/
mac
/
software
/
wissen
/
daten
/
gnuplot.hqx
/
gnuplot.2.0b4
/
Interapplication
/
C Examples
/
wackyconsole.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-09-15
|
1KB
|
52 lines
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <SIOUX.h>
#include "gnuplotInterface.h"
char gnuplotSays[4096] = "";
char inputStr[1024] = "";
void FlipLineEndings(char *str);
void main(void)
{
int keepGoing = 1;
int success;
SIOUXSettings.asktosaveonclose = false;
puts("This is the wacky console..."); /* This line intitializes the mac */
success = GnuplotLaunchApplication();
if (success == 0)
fputs("gnuplot successfully launched!\ngnuplot> ", stderr);
else {
fputs("unable to launch gnuplot\n", stderr);
return;
}
GnuplotExecuteCommand(" \n", 2, gnuplotSays, 4095);
while (keepGoing) {
fgets(inputStr, 1024, stdin);
keepGoing = strcmp(inputStr, "quit\n") && strcmp(inputStr, "exit\n");
/* Don't send the "quit" command via ...ExecuteCommand because we will have to
wait for the AE timeout. We really don't want to do that. */
if (keepGoing) {
GnuplotExecuteCommand(inputStr, strlen(inputStr), gnuplotSays, 4095);
FlipLineEndings(gnuplotSays);
fputs(gnuplotSays, stdout);
}
else
GnuplotQuitApplication();
}
fputs("Goodbye!", stderr);
return;
}
void FlipLineEndings(char *str)
{
while (*str) {
if (*str == '\r')
*str = '\n';
str++;
}
}